//
//  ViewController.m
//  10505
//
//  Created by student on 16/2/19.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)slider1:(UISlider *)sender {
    int value = sender.value;
    _tv1.text =[NSString stringWithFormat:@"%i",value];
}
- (IBAction)slider2:(UISlider *)sender {
    int value = sender.value;
    _tv2.text =[NSString stringWithFormat:@"%i",value];
}
- (IBAction)slider3:(UISlider *)sender {
    int value = sender.value;
    _tv3.text =[NSString stringWithFormat:@"%i",value];
}

- (IBAction)changeColor:(id)sender {
    self.imageView.backgroundColor = [UIColor colorWithRed:_slider1.value/255.0 green:_slider2.value/255.0 blue:_slider3.value/255.0 alpha:0.5];
}
- (IBAction)tv1:(UITextField *)sender {
    NSString *str = sender.text;
    if ([str intValue] > 255)
    {
        sender.text = [NSString stringWithFormat:@"255"];
    }
    _slider1.value = [str intValue];
}
- (IBAction)tv2:(UITextField *)sender {
    NSString *str = sender.text;
    if ([str intValue] > 255)
    {
        sender.text = [NSString stringWithFormat:@"255"];
    }
    _slider2.value = [str intValue];
}
- (IBAction)tv3:(UITextField *)sender {
    NSString *str = sender.text;
    if ([str intValue] > 255)
    {
        sender.text = [NSString stringWithFormat:@"255"];
    }
    _slider3.value = [str intValue];
}

- (IBAction)tvChangeColor:(id)sender {
    self.imageView.backgroundColor = [UIColor colorWithRed:_slider1.value/255.0 green:_slider2.value/255.0 blue:_slider3.value/255.0 alpha:0.5];
}
- (IBAction)Tap:(UIControl *)sender {
    [self.view endEditing:YES];
}


@end
